﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;

namespace TCCT_CTC_CSDLDangVienV1.DanhMuc
{
    public partial class frmDauMoiUpdate : frmBase
    {
        private string action;

        public string Action
        {
            set { action = value; }
        }
        public string SelectedID = string.Empty;
        private string MaDanhMuc = string.Empty;
        private bool IsFormFind = false;

        public frmDauMoiUpdate()
        {
            InitializeComponent();
            if (action == MyConst.ACTION.Insert)
            {
                MessageBox.Show("Insert");
            }
            else if (action == MyConst.ACTION.Update)
            {
                MessageBox.Show("Update");
            }
        }

        public frmDauMoiUpdate(string maDanhMuc)
        {
            this.MaDanhMuc = maDanhMuc;
            InitializeComponent();
        }


        private void frmDauMoiUpdate_Load(object sender, EventArgs e)
        {
            try
            {
                this.Text = MaDanhMuc;
                
                ApplyUI();


            }
            catch (Exception _ex)
            {
                ShowErrorMessage(_ex);
            }
        }

        //Nơi gán thuộc tính giao diện cho các control
        private void ApplyUI()
        {
            UI.Button.ApplyInsert(btnOk);
            UI.Button.ApplyInsert(btnCancel);

            UI.TextBox.ApplyDefault(txtSoCB);
            UI.TextBox.ApplyDefault(txtLoai);
            UI.TextBox.ApplyDefault(txtKy_Hieu);
            UI.TextBox.ApplyDefault(txtMaDV);
            UI.TextBox.ApplyDefault(txtTenDV);
            UI.TextBox.ApplyDefault(txtViet_Tat);

        }

        private void BindDataToDropdown()
        {
            string sql = "SELECT * FROM tblDauMoi";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            

        }

        private void btnCapTren_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            MyCommon.MyTuDien("1", sender, MyConst.TD.CVCD.Ma, MyConst.TD.CVCD.Ten);//Sửa mã từ đienr truyền vào cho thích hợp
        }
    }
}